package edu.wuster.blog.mapper;


import edu.wuster.blog.entity.Label;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;



import java.util.List;

@Mapper
public interface LabelMapper {

    @Insert("insert into label(blog_id,name) values (#{blogId},#{name})")
    //@Insert("insert into label(blog_id,name) values (#{blogId},#{name}) select blog.id = label.blog_id  from blog where is_delete = 0 ")
    void addLabel(Label label);

    @Select("select name from label where name = #{name} and blog_id = #{blogId}")
    Label selectAdded(Label label);

    @Delete("delete from label where id = #{id} ")
    void deleteLabel(Integer id);

    @Select("select * from label where blog_id = #{blogId} ")
    List<Label> selectByBlogId(Integer blogId);

    @Select("select * from label where id = #{id} ")
    Label selectById(Integer id);


}
